import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class BgArcWidget extends StatelessWidget {
  final Color bgColor;

  const BgArcWidget({Key key, @required this.bgColor}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      width: ScreenUtil.getInstance().setWidth(750),
      height: ScreenUtil.getInstance().setHeight(400),
      child: CustomPaint(
        size: Size(ScreenUtil.getInstance().setWidth(750), ScreenUtil.getInstance().setHeight(500)),
        painter: BgArc(bgColor: bgColor),
      ),
    );
  }
}

class BgArc extends CustomPainter {
  final Color bgColor;

  BgArc({this.bgColor});

  @override
  void paint(Canvas canvas, Size size) {
    double w = size.width;
    double h = size.height;

    Paint paint = Paint()
      ..isAntiAlias = true
      ..strokeWidth = 5
      ..color = bgColor
      ..strokeCap = StrokeCap.round
      ..style = PaintingStyle.fill;

//    canvas.drawPoints(PointMode.points, [Offset(0, h - h / 4), Offset(w, h - h / 4)], paint);

    Path path = Path();
    path.moveTo(0, h - 50);
    path.quadraticBezierTo(w / 2, h + 40, w, h - 50);
    path.lineTo(w, 0);
    path.lineTo(0, 0);
    path.close();

    canvas.drawPath(path, paint);
  }

  @override
  bool shouldRepaint(CustomPainter oldDelegate) {
    return true;
  }
}
